package com.ccys.cms.controller.administrator;

import com.ccys.cms.service.administrator.TblDeliveryTimeSlotWebService;
import com.ccys.common.constants.ContextConstants;
import com.ccys.common.util.Kit;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.administrator.TblDeliveryTimeSlotDTO;
import com.ccys.db.entity.TblDeliveryTimeSlot;
import com.ccys.db.vo.administrator.TblDeliveryTimeSlotWebVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@Api(tags = "系统设置-delivery timeslots 快递时段-Time")
@RequestMapping("administrator")
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE, RequestMethod.PUT}) // 开启跨域访问允许
@SuppressWarnings("unchecked")
public class DeliveryTimeSlotWebController {

    @Autowired
    private TblDeliveryTimeSlotWebService tblDeliveryTimeSlotWebService;

    @GetMapping("deliveryTimeSlot")
    @ApiOperation("获取列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dcId", value = "关联对象ID", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlStatus", value = "dtlStatus", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlDay", value = "dtlDay", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlForDeliveryType", value = "dtlForDeliveryType", required = false, dataType = "string", paramType = "query"),


            @ApiImplicitParam(name = "id", value = "对象id", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "orderByStr", value = "排序字段（后端返回的字段  asc升序，desc 降序,加上end后缀。示例（createdOn降序排 则传值 createdOn descend））",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = TblDeliveryTimeSlotWebVO.class)
    })
    public ResponseResult listObjectsCms(HttpServletRequest request, HttpServletResponse response, @ApiIgnore TblDeliveryTimeSlotDTO dto) {
        return this.tblDeliveryTimeSlotWebService.listObjectsCms(request, response, dto);
    }


    @PostMapping("deliveryTimeSlot")
    @ApiOperation("添加")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dcId", value = "dcId", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlStartTime", value = "dtlStartTime", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlEndTime", value = "dtlEndTime", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlStatus", value = "dtlStatus", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlDispOrder", value = "dtlDispOrder", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlIsShow", value = "是否在 CMS 展示，默认 1，目前没地方可以修改", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlForDeliveryType", value = "快递方式 2:standard 3:express", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlDay", value = "dtlDay", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlFeeAmount", value = "dtlFeeAmount", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult save(HttpServletRequest request, HttpServletResponse response, @ApiIgnore TblDeliveryTimeSlot entity) {
        entity.setId(null);
        return this.tblDeliveryTimeSlotWebService.change(request, response, entity);
    }


    @PutMapping("deliveryTimeSlot")
    @ApiOperation("编辑")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dcId", value = "dcId", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlStartTime", value = "dtlStartTime", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlEndTime", value = "dtlEndTime", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlStatus", value = "dtlStatus", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlDispOrder", value = "dtlDispOrder", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlIsShow", value = "是否在 CMS 展示，默认 1，目前没地方可以修改", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlForDeliveryType", value = "快递方式 2:standard 3:express", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlDay", value = "dtlDay", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dtlFeeAmount", value = "dtlFeeAmount", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult edit(HttpServletRequest request, HttpServletResponse response, @ApiIgnore TblDeliveryTimeSlot entity) {
        Kit.allParamValid(entity, "id");
        return this.tblDeliveryTimeSlotWebService.change(request, response, entity);
    }


    @DeleteMapping("deliveryTimeSlot")
    @ApiOperation("删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID号", required = true, dataType = "string", paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult delete(HttpServletRequest request, HttpServletResponse response, TblDeliveryTimeSlot dto) {
        Kit.allParamValid(dto, "id");
        return this.tblDeliveryTimeSlotWebService.delete(request, response, dto);
    }

}